Repository navigation
fix(maker): harden maker inputs from audit Low findings - #9
Merged
Merged
Conversation
The --method option was rendered verbatim into the data provider skeleton, so a crafted value could inject arbitrary PHP into the generated class. Validate it as a PHP identifier like make:hook does.
PackageContext::packageRelativePath() only stripped leading slashes, so make:asset-entry --path=Resources/../../../x.ts wrote outside the package and project. Run the result through ProjectPath::relative(), which rejects traversal segments, absolute paths and symlink escapes, as make:sympress-package --path already does.
The handle was written verbatim into a // or /* */ comment of the generated TS/SCSS entry, so a newline or "*/" could inject code. Accept only the WordPress handle convention (lowercase letters, digits, "-" and "_"), which also covers handles derived from the entry name.
Generator::dumpFile() has no existence check, so re-running make:block after renaming or deleting the block class silently replaced a maintained block.json, editor/frontend entry and view template. Fail like generateClass() does when one of these files already exists.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The 2026-11-15 audit reported four Low findings in generator input handling (exploitable by whoever feeds the maker commands, e.g. scripts or coding agents passing ticket text):
make:data-provider --methodwas rendered verbatim into the skeleton, allowing arbitrary PHP in the generated class.make:asset-entry --pathhad no traversal check:PackageContext::packageRelativePath()only stripped leading slashes, soResources/../../../x.tswrote outside the package and project.make:asset-entry --handlewas written raw into a////* */comment in the generated TS/SCSS file; a newline or*/broke out of it.make:blocksilently overwrote an existingblock.json, editor/frontend entry and view (Generator::dumpFile()has no existence check).Fix
MakeDataProvider: validate the method withSourceLiteral::identifier(), asMakeHookdoes.PackageContext::packageRelativePath(): pass the result throughProjectPath::relative()(rejects..segments, absolute paths, NUL and symlink escapes; same guard asmake:sympress-package --path). This covers every caller (make:asset-entry,make:block).MakeAssetEntry: accept only handles matching^[a-z0-9][a-z0-9_-]*$(WordPress handle convention); applies to explicit and derived handles.MakeBlock: fail withThe file "…" can't be generated because it already exists.(same wording/behaviour as MakerBundle'sgenerateClass()) before queuing any write. No--forcewas added since no such pattern exists in the bundle.All checks run before
writeChanges(), so a rejected run writes nothing.Behaviour note: a package whose directory is a symlink pointing outside the project root can no longer receive generated asset/block files (it is treated as an escape).
Tests
New
tests/Maker/MakerInputSafetyTest.phpruns the makers end to end against a temp workspace. Each test was verified to fail onmainand pass with the fix:InvalidArgumentException, nothing written--path=Resources/../../../escape.ts→ rejected, no file outside the package, no webpack config\nand*/→ rejectedblock.json→ refused and preserved; after removing it the block (incl. view) generates normallyLocal QA (PHP 8.5 container):
composer validate --strictvalid,composer csOK,composer static-analysisno errors,composer testsOK (23 tests, 176 assertions).Release
Patch:
1.0.4(CHANGELOG entry, includes the unreleased CI pin tosympress/workflowsv1.3.2). Tagv1.0.4/ release titlev1.0.4after merge.